// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        m_label: cc.Label,
        m_lock: cc.Node,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },

    init(index, locked, callback) {
        this.m_label.string = ""+(index);
        this.m_lock.active = locked

        this.index = index;
        this.locked = locked;
        this.callback = callback;
    },

    onClickButton(sender) {
        if (this.locked)
            return;
        this.callback(this.index);
    },
});
